package test0109;

import java.util.HashMap;
import java.util.Map;

public class Test06 {
    public static void main(String[] args) {
        // (6)统计字符串中每个字符出现的次数、map集合实现
        String s = "sdfjkshdfjkkjwehrwer";
        Map<Character, Integer> map = new HashMap<Character, Integer>();

        for (int i = 0; i < s.length(); i++) {
            char x=s.charAt(i);
            int y=0;
            for(int j=0;j<s.length();j++){
                if(x==s.charAt(j)){
                    y++;
                }
            }
            map.put(x,y);
        }
        map.forEach((k,v)->{
            System.out.println(k+"出现次数"+v);
        });
    }
}
